package cn.hznc.controller.toolAnalyze;

import cn.hznc.controller.service.toolAnalyze.ToolLifeAnalyzeService;
import cn.hznc.domain.entity.ToolLifeAnalyzeDetailEntity;
import cn.hznc.domain.entity.ToolLifeAnalyzeEntity;
import cn.hznc.domain.request.life.QryToolLifeReq;
import cn.hznc.domain.request.toolAnalyze.ToolLifeAnalyzeReq;
import cn.hznc.domain.response.PageResult;
import cn.hznc.domain.response.ResponseBody;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/toolLifeAnalyze")
public class ToolLifeAnalyzeController {

    @Resource
    private ToolLifeAnalyzeService toolLifeAnalyzeService;
//    @RequestMapping(value = "/queryToolLifeAnalyze", method = RequestMethod.POST)
//    public ResponseBody<PageResult<ToolLifeAnalyzeEntity>> queryToolLifeAnalyze(@RequestBody ToolLifeAnalyzeReq toolLifeAnalyzeReq) {
//        return ResponseBody.success(toolLifeAnalyzeService.queryToolLifeAnalyze(toolLifeAnalyzeReq));
//    }

    @RequestMapping(value = "/queryToolLifeAnalyze", method = RequestMethod.POST)
    public ResponseBody queryToolLifeAnalyze(@RequestBody QryToolLifeReq qryToolLifeReq) {
        return ResponseBody.success(toolLifeAnalyzeService.queryToolLifeAnalyze(qryToolLifeReq));
    }




    @RequestMapping(value = "/queryPartnosById", method = RequestMethod.GET)
    public ResponseBody queryPartnosById(@RequestParam("ids") List<Integer> ids) {
        return ResponseBody.success(toolLifeAnalyzeService.queryPartnosById(ids));
    }


    @RequestMapping(value = "/queryToolLifeAnalyzeDetailByPartno", method = RequestMethod.GET)
    public ResponseBody<PageResult<ToolLifeAnalyzeDetailEntity>> queryToolLifeAnalyzeDetailByPartno(@RequestParam Integer pageNo,
                                                                                                    @RequestParam Integer pageSize,
                                                                                                    @RequestParam String partno,
                                                                                                    @RequestParam String uniqueId,
                                                                                                    @RequestParam(required = false) Integer isDamage) {
        return ResponseBody.success(toolLifeAnalyzeService.queryToolLifeAnalyzeDetailByPartno(pageNo,pageSize,partno,uniqueId,isDamage));
    }
}
